_agentTypes =["Sportswoman5"];
//_agentTypes =["Citizen1"]; //Secretary1

/* ========================================================= */
/*           Dont change this point bellow                   */
/* ========================================================= */
// Some Macros
#define GetRandomElem(_myarray) _myarray select (random (count _myarray - 1))
/* ========================================================= */
_fnc_w_sit = compile preprocessFile "transportation\animations\w_sit.sqf";
_fnc_w_standUp = compile preprocessFile "transportation\animations\w_standUp.sqf";
_fnc_w_walk = compile preprocessFile "transportation\animations\w_walk.sqf";
_fnc_w_sit_smoking = compile preprocessFile "transportation\animations\w_sit_smoking.sqf";
_fnc_w_sit_idle = compile preprocessFile "transportation\animations\w_sit_idle.sqf";

/* ========================================================= */
/* ========================================================= */
_maker = _this select 0;
_mygroup = createGroup civilian;
_pos = position _maker;
deleteVehicle _maker;
sleep 2;
_myChair = "FoldChair_with_Cargo" createVehicle _pos;
_myChair setPos _pos;
_myChair setPosATL (getPosATL _myChair);
_myChair setDir 0;
[_myChair] join _mygroup ;
_agent = _mygroup createUnit [GetRandomElem(_agentTypes), position _myChair, [], 0, "NONE"];
_agent disableAI "ANIM";
_agent disableAI "MOVE";
_agent disableAI "FSM";
_agent setPosATL ([(getPos _myChair select 0)  ,(getPos _myChair select 1)+ 0.8,0]);
_agent setDir (getDir _myChair) -180;
// -----------------------------------------
_currentStanza = "sit";
_agent addEventHandler ["killed", {(_this select 0) setVariable ['killer',(_this select 1)]}];
_w = [_agent,_myChair] call _fnc_w_sit;
while {alive _agent} do {
	_anim = ceil (random 8);
	_nearbuddies = (nearestObjects [_agent, ["Man","Woman"], 10]) - [_agent];
	{if (isPlayer _x) then {
		_players =_players + 1};
	} forEach _nearbuddies;
	
	if (_w > 0) then { 
		sleep 1; 
		_w = _w - 1;
	}	else {
		// hint format ["Stanza %1 - anim %2",_currentStanza,_anim];
		switch (_currentStanza) do {
			case ( "sit" ): { 
				switch (true) do {
					case ( _anim >= 1 and _anim <= 6): { 
						_w = [_agent,_myChair,1] call _fnc_w_sit_idle;
					};		
					case ( _anim == 7 ): { 
						_w = [_agent,_myChair] call _fnc_w_standUp;
						_currentStanza = "stand";
					};			
					case ( _anim == 8 ): { 
						_w = [_agent,_myChair] call _fnc_w_sit_smoking;
					};		
					default {
						//sleep 2;
						_w = 2;
					};				
				};
			};
			case ( "stand" ): { 
				switch (true) do {
					case ( _anim == 1 ): { 
						_w = [_agent,_myChair] call _fnc_w_sit;
						_currentStanza = "sit";
					};
					case ( _anim == 2 ): { 
						_w = [_agent,_myChair] call _fnc_w_walk;
					};
					default {
						//sleep 2;
						_w = 2;
					};
				};
			};
		};
	};

};
if (_currentStanza == "stand") then {
	_agent enableAI "ANIM";
};
sleep 1;
titleText ["You have killed a Global Transportation Co. Employee","PLAIN",1];
sleep 1;
cutText ["You will suffer the consequences of your actions!","PLAIN DOWN",1];

_killer = (_agent getVariable "killer");
null = [position (_agent getVariable "killer"),(_agent getVariable "killer")] execVM "transportation\initHeliInsertion.sqf"; 

	

		/*_armygroup = createGroup civilian;
		for "_x" from 1 to 4  do {
			_soldier = _armygroup createUnit ["Poet_PMC", getPos MARKER_1, [], 0, "NONE"];
			[_soldier] join _armygroup ;
		};
		[_armygroup,_killer] execVM "transportation\huntKiller.sqf";*/

//_agent switchMove "ActsPsitMstp_Smoking";
//_agent playMove "ActsPsitMstp_idleLoop";
